ioemu: strip tap subtype prefix from image name
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 30 Jan 2008 14:25:55 +0000 (14:25 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 30 Jan 2008 14:25:55 +0000 (14:25 +0000)
Currently I am not able to mount or boot from an HVM CDROM when it is
configured for 'tap:aio' instead of 'file'.

disk=[ 'tap:aio:/var/lib/xen/images/sles10-sp2-fv/disk0,hda,w', '
       tap:aio:/home/iso/sles/SLES10.iso,hdc:cdrom,r', ]

With this patch I am able to boot from the CDROM and or mount it.

Patch changes xenstore.c:xenstore_process_event() to strip the tap
subtype prefix from the image name.

Signed-off-by: Pat Campbell <plc@novell.com>
tools/ioemu/xenstore.c

index 2d239fe1bbe3bd1d8593059bb34a0dde0f57a49c..2905c794599b3af5a6e69b32dacbaa4c66bb4b48 100644 (file)
@@ -419,7 +419,7 @@ void xenstore_record_dm_state(char *state)
 
 void xenstore_process_event(void *opaque)
 {
-    char **vec, *image = NULL;
+    char **vec, *offset, *bpath = NULL, *buf = NULL, *drv = NULL, *image = NULL;
     unsigned int len, num, hd_index;
 
     vec = xs_read_watch(xsh, &num);
@@ -441,8 +441,28 @@ void xenstore_process_event(void *opaque)
         goto out;
     hd_index = vec[XS_WATCH_TOKEN][2] - 'a';
     image = xs_read(xsh, XBT_NULL, vec[XS_WATCH_PATH], &len);
-    if (image == NULL || !strcmp(image, bs_table[hd_index]->filename))
-        goto out;  /* gone or identical */
+    if (image == NULL)
+        goto out;  /* gone */
+
+    /* Strip off blktap sub-type prefix */
+    bpath = strdup(vec[XS_WATCH_PATH]); 
+    if (bpath)
+        goto out;
+    if ((offset = strrchr(bpath, '/')) != NULL) 
+        *offset = '\0';
+    if (pasprintf(&buf, "%s/type", bpath) == -1) 
+        goto out;
+    drv = xs_read(xsh, XBT_NULL, buf, &len);
+    if (drv) {
+        if (!strcmp(drv, "tap")) {
+            offset = strchr(image, ':'); 
+            if (offset) 
+                memmove(image, offset+1, strlen(offset+1)+1 );
+        }
+    }
+
+    if (!strcmp(image, bs_table[hd_index]->filename))
+        goto out;  /* identical */
 
     do_eject(0, vec[XS_WATCH_TOKEN]);
     bs_table[hd_index]->filename[0] = 0;
@@ -457,6 +477,9 @@ void xenstore_process_event(void *opaque)
     }
 
  out:
+    free(drv);
+    free(buf);
+    free(bpath);
     free(image);
     free(vec);
 }